home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / games / spassion / source.lzh / SOURCE / FuncEnemy / HATCH.C < prev    next >
Text File  |  2000-03-20  |  3KB  |  151 lines

  1. /*
  2. #include <stdio.h>
  3. #include <iocslib.h>
  4. void    key_wait( void );
  5. #define BIT(i)        (1<<(i))
  6. */
  7. /* ハッチ */
  8. #include <xsp2lib.h>
  9. #include "../SPASSION.H"
  10. #include "../player.h"
  11. #include "../enemy.h"
  12. #include "../eshot.h"
  13. #include "../effect.h"
  14. #include "../priority.h"
  15. #include "../sound.h"
  16. #include "../entry.h"
  17. #ifndef NULL
  18. #define NULL ((void *) 0)
  19. #endif
  20.  
  21. #define PALET_MAIN    0x0500
  22.  
  23. static short MoveEnemyHatch(ENEMY *);
  24. /*static void TiniEnemyHatch(ENEMY *);*/
  25.  
  26. #define PT_ST    0x0
  27. #define PT_END    0x4
  28.  
  29. /* 32x16キャラの当たり判定 */
  30. static HIT_XY4    hit_p[]={-16-PLAYER_HIT_X,-8-PLAYER_HIT_Y,16+PLAYER_HIT_X,8+PLAYER_HIT_Y};
  31. static HIT_XY4    hit_o[]={-16-OPTION_HIT_X,-8-OPTION_HIT_Y,16+OPTION_HIT_X,8+OPTION_HIT_Y};
  32. static HIT_XY4    hit_s[]={-16,-8,16,8};
  33.  
  34. void InitEnemyHatchHit( void )
  35. {
  36. }
  37. static short    pt_st[2]={0,5},pt_end[2]={4,9};
  38.  
  39. void InitEnemyHatch(ENEMY *ene)
  40. {
  41.     ene->pt             = obj_hatch+pt_st[ene->arg];
  42.     ene->info         = PALET_MAIN | PRIORITY_ZAKO+1;
  43.     ene->vx             = -map_vx;
  44.     ene->vy             = 0;
  45.     ene->hit_p[0]     = &hit_p[0];ene->hit_p[1]=NULL;
  46.     ene->hit_o[0]     = &hit_o[0];ene->hit_o[1]=NULL;
  47.     ene->hit_s[0]     = &hit_s[0];ene->hit_s[1]=NULL;
  48.     ene->hp             = 10;
  49.     ene->work         = 0;
  50.     ene->no_dead     = 0;
  51.     ene->func_enemy_move = MoveEnemyHatch;
  52. /*    ene->func_enemy_tini = TiniEnemyHatch;*/
  53.  
  54. /*    entry_counter_stop = !0;*/        /* エントリーカウンター停止 */
  55. }
  56.  
  57.  
  58. static short MoveEnemyHatch( ENEMY *ene )
  59. {
  60.     short Wait( ENEMY *ene, short time );
  61.  
  62.     /* 速度を足して上位ワード(固定整数部)だけ取り出す */
  63.     ene->x = ((ene->lx += ene->vx) >> 16);
  64.     ene->y = ((ene->ly += ene->vy) >> 16);
  65.  
  66.     switch (ene->state){
  67.     case 0:
  68.         if( Wait( ene, 20) )ene->state++;
  69.         break;
  70.     case 1:
  71.         ene->pt = obj_hatch+pt_st[ene->arg]+(ene->anim_count++)/4;
  72.         if( ene->pt > obj_hatch+pt_end[ene->arg] ){
  73.             ene->pt = obj_hatch+pt_end[ene->arg];
  74.             ene->anim_count=0;
  75.             ene->state++;
  76.         }
  77.         break;
  78.     case 2:
  79.         if( Wait( ene, 20) )ene->state++;
  80.         break;
  81.     case 3:
  82.         if( ene->work++ > 12 ){
  83.             MakeEnemy(ENEMY_ZAKO05, ene->x, ene->y,ene->arg, ene);
  84.             ene->work=0;
  85.             if( ene->work2++ > 5 ){        /* 5機出す */
  86.                 ene->work2=0;
  87.                 ene->state++;
  88.             }
  89.         }
  90.         break;
  91.     case 4:
  92.         if( Wait( ene, 20) )ene->state++;
  93.         break;
  94.     case 5:
  95.         ene->pt = obj_hatch+pt_end[ene->arg]-(ene->anim_count++)/4;
  96.         if( ene->pt < obj_hatch+pt_st[ene->arg] ){
  97.             ene->pt = obj_hatch+pt_st[ene->arg];
  98.             ene->anim_count=0;
  99.             ene->state++;
  100.         }
  101.         break;
  102.     case 6:
  103.         if( Wait( ene, 60) )ene->state=0;
  104.         break;
  105.     }
  106.     /* 画面外に出たら消去 */
  107.     if( ENE_X < 0 - 32 )
  108.         return (0);
  109.  
  110. #if 0
  111.         if(ENE_X < 128){
  112.             ene->lx = 128*65536;
  113.             ene->vx = 0;
  114.             ene->vy = 0;
  115.         }
  116.             if( BITSNS(0x04) & BIT(1) ){
  117.                 while( BITSNS(0x04) & BIT(1) );
  118.                 entry_counter_stop = 0;
  119.                 return (0);
  120.             }
  121. #endif
  122.  
  123. /*
  124. printf("x=%d vx=%d\n",ene->x,ene->vx);
  125. key_wait();
  126. */
  127.     /* ダメージを受けた時の処理 */
  128.     if(ene->damage){
  129.         SetSE(SE_DAMAGE);    /* 効果音 */
  130.         ene->info = PALET_DAMAGE | PRIORITY_ZAKO+1;
  131.         if((ene->hp -= ene->damage) <= 0) {
  132.             MakeEffect(EFFECT_EXPL, 0, ene->x-8, ene->y-8);
  133.             SetSE(SE_EXPL_HATCH);    /* 爆発音 */
  134.             ene->player->score += 3;
  135.             return (0);        /* 消去 */
  136.         }
  137.         ene->damage = 0;
  138.     }else
  139.         ene->info = PALET_MAIN | PRIORITY_ZAKO+1;
  140.  
  141.     xobj_set_st(ene);
  142.  
  143.     return(1);
  144. }
  145.  
  146. /*
  147. static void TiniEnemyHatch(ENEMY * p)
  148. {
  149. }
  150. */
  151.